package ex3.reversi;

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;

import ex3.board.ConfigClass;
import ex3.board.GameBoard;

/**
 * This class represent the turn selection before starting the game in one mode player.
 * 
 * @author Maxim
 *
 */
public class TurnChoise extends JFrame implements ActionListener{

	private static final long serialVersionUID = 1L;
	
	private JButton _player;
	private JButton _computer;
	
	
	public TurnChoise(){
		super("Please choose who will start the game");
		
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.getContentPane().setLayout(new GridLayout(2,1));
		this._computer = new JButton("Computer");
		this._player = new JButton("Player");
		this._computer.addActionListener(this);
		this._player.addActionListener(this);
		this.getContentPane().add(this._player);
		this.getContentPane().add(this._computer);
		this.setSize(500,150);
		this.setResizable(true);
		this.setVisible(true);
		
	}
	
	
	@Override
	public void actionPerformed(ActionEvent e) {
		
		if (e.getSource().equals(this._player)){

			GameBoard c = new GameBoard("REVERSI GAME", ConfigClass.ONE_PLAYER_MODE ,  ConfigClass.BLACK_PLAYER);
			c.setSize(700, 700);
			c.setVisible(true);
			this.dispose();
		}
			
		if (e.getSource().equals(this._computer)){
			
			GameBoard c = new GameBoard("REVERSI GAME", ConfigClass.ONE_PLAYER_MODE,ConfigClass.WHITE_PLAYER);
			c.setSize(700, 700);
			c.setVisible(true);
			this.dispose();
		
		}
	}
	
	
	

}
